package com.example.understand_compose1.fet_databaseusage.presentation

import android.os.Bundle
import android.widget.RadioGroup
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import com.example.understand_compose1.R
import com.example.understand_compose1.fet_databaseusage.data.DatabaseHelper

class FetRadioButtonAndDatabaseActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.test_radiobutton)
        // TODO:一旦调用，马上创建数据库xxx.db
        val dbhelper = DatabaseHelper(this);
        dbhelper.writableDatabase


        val rg: RadioGroup = findViewById(R.id.rg1)

        val tv: TextView = findViewById(R.id.tv1)

        // TODO:
        rg.setOnCheckedChangeListener { group, checkedId ->
            when (checkedId) {
                R.id.rb1 -> {
                    tv.setText("北京")
                }
                R.id.rb2 -> {
                    tv.setText("上海")
                }
                R.id.rb3 -> {
                    tv.setText("广州")
                }
                R.id.rb4 -> {
                    tv.setText("深圳")
                }
            }

        }

    }
}